<section id="category" class="sub-cate group1">
    <div class="content-wrap">

            <header>
                <h1>
                <a href="<?=base_url().$cate_info->category_links?>" title="<?=$category_name?>"><?=$category_name?></a> <?=$sub_info->sub_category_name?></h1>

            </header>

            <section class="cate_content">

                    <section class="featured">
                    <!-- Tin Nổi bật Chuyên mục -->

                        <?php
                        $CI = & get_instance();
                        $CI->load->model('mindex');
                        $topicOne = $CI->mindex->getTopicTop1BySub($sub_info->sub_category_id);
                        if ($topicOne):
                    ?>
                    <!-- Tin Nổi bật Chuyên mục -->
                    <article class="featured ">
                        <p class="type"></p>
                        <div class="cover" style="background-image: url(<?=base_url().$topicOne->topic_news_picture?>)">
                        <a href="<?=site_url('home/detail').'/'.$topicOne->topic_news_id?>"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="<?=site_url('home/detail').'/'.$topicOne->topic_news_id?>">
                         <?php echo $topicOne->topic_news_title; ?>
                        </a>

                        </h1>
                        <time datetime=" <?=date('Y-m-d H:i:s', $topicOne->topic_news_date)?>"></time>
                        <p class="cate"> <?php echo $category_name; ?></p>
                        <p class="summary"><?php echo substr(strip_tags($topicOne->topic_news_content), 0,250).'...'; ?></p>
                        </header>
                    </article>
                    <?php endif; ?>
                    <?php
                        $topicTop3 = $CI->mindex->getTopicTop3BySub($sub_info->sub_category_id);
                        if ($topicTop3):
                            foreach ($topicTop3 as $topic) {
                    ?>
                    <article>
                        <div class="cover" style="background-image: url(<?=base_url().$topic->topic_news_picture?>)">
                        <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>">
                        <?=$topic->topic_news_title?>
                        </a>

                        </h1>
                        <time datetime="<?=date('Y-m-d H:i:s', $topic->topic_news_date)?>"></time>
                        <p class="cate"><?php echo $category_name; ?></p>
                        </header>
                    </article>
                    <?php  } endif; ?>

                    </section>


                    <section class="cate_content">

                            <header>
                            <h1>Mới nhất</h1>
                            <a href="javascript:showBoxAds();" title="Đăng thông tin">Liên hệ Quảng cáo
                            </a>
                            </header>
                        <?php
                                $topicNews = $CI->mindex->getTopicBySub($sub_info->sub_category_id);
                                if ($topicNews):
                                    foreach ($topicNews as $key=>$topic) {
                        ?>
                        <article class="<?php
                                        if ($topic->topic_news_type == "video") {
                                            echo "hasvideo";
                                        } elseif ($topic->topic_news_type == "picture") {
                                            echo "picture";
                                        } else {
                                            echo "";
                                        }
                                        ?>">
                                    <p class="type"></p>
                                    <div class="cover" style="background-image: url(<?=base_url().$topic->topic_news_picture;?>)">
                                    <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>"></a>
                                    </div>
                                    <header>
                                    <h1>
                                    <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>">
                                    <?=$topic->topic_news_title?>
                                    </a>
                                    <span class="social"><?=$topic->topic_news_id?></span>
                                    </h1>
                                    <time datetime="<?=date('Y-m-d H:i:s', $topic->topic_news_date)?>"></time>
                                    <p class="cate"><?php echo $category_name; ?></p>
                                    <p class="summary"><?php echo substr(strip_tags($topic->topic_news_content), 0,200).'...'; ?></p>
                                    </header>
                                <ul class="relate">
                                    <?php 
                                        $topicTag = $CI->mindex->getTopicTag($topic->topic_news_id,$topic->topic_news_tag);
                                        if($topicTag):
                                            foreach ($topicTag as $top) {
                                    
                                        ?>
                                        <li class="<?php
                                            if ($top->topic_news_type == "video") {
                                                echo "hasvideo";
                                            } elseif ($top->topic_news_type == "picture") {
                                                echo "picture";
                                            } else {
                                                echo "";
                                            }
                                            ?>"><a href="<?=site_url('home/detail').'/'.$top->topic_news_id?>" title="<?=$top->topic_news_title?>">
                                         <?=$top->topic_news_title?></a></li>
                                    <?php } endif;?>
                            </ul>
                        </article>
                        <?php } endif;?>

                            <p class="more">
                            <span id="ctl00_mainContent_ctl00_ContentList1_pager"><a id="ctl00_mainContent_ctl00_ContentList1_pager_nextControl" href="http://news.zing.vn/xa-hoi/doi-song/trang2.html">Xem thêm</a></span>
                            </p>
                    </section>

            </section>
    </div>

    <section class="sidebar">

            <div id="advR1" class="banner">
                <div style="height: 250px; left: 866.5px; top: 192px;" id="advR1_temp">
                    <script>
                    if ($(document).width() > 1000) {
                    vng_ads.showBannerR1();
                    }
                    </script><!-- 123Click Ads Code begin -->
                    <script type="text/javascript">
                    (function(d, s, id) {
                    var js, fjs = d.getElementsByTagName(s)[0];
                    if (d.getElementById(id)) {return;}
                    js = d.createElement(s);
                    js.type = 'text/javascript';
                    js.async=true;
                    js.id = id;
                    js.src = "http://static.adtimaserver.vn/resource/js/zads-base-mod.js";
                    fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'z2-jssdk'));
                    </script>
                    <div z2-zoneid="2328465490092448928" z2-width="300" z2-height="250" class="z2-zads-zone"></div>
                </div>
            </div>
            <div id="advR2" class="banner">
                <div style="height: 250px; left: 866.5px; top: 447px;" id="advR2_temp">
                    <script>
                        if ($(document).width() > 1000) {
                        vng_ads.showBannerR2();
                        }
                        </script><!-- 123Click Ads Code begin -->
                        <script type="text/javascript">
                        (function(d, s, id) {
                        var js, fjs = d.getElementsByTagName(s)[0];
                        if (d.getElementById(id)) {return;}
                        js = d.createElement(s);
                        js.type = 'text/javascript';
                        js.async=true;
                        js.id = id;
                        js.src = "http://static.adtimaserver.vn/resource/js/zads-base-mod.js";
                        fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'z2-jssdk'));
                    </script>
                    <div z2-zoneid="649683947998370983" z2-width="300" z2-height="250" class="z2-zads-zone"></div>
                </div>
            </div>

            <!-- End 123.vn -->

            <!-- Start Box Sidebar -->

            <section class="order-list">
                <header>
                <h1><a title="Đọc nhiều nhất">Đọc nhiều nhất</a></h1>
                </header>
                <?php
                        $topicReadless = $CI->mindex->getTopicReadlessBySub($sub_info->sub_category_id);
                        if ($topicReadless):
                            foreach ($topicReadless as $key=>$topic) {
                ?>
                <article>
                    <span class="order"><?=$key+1?></span>
                    <div class="cover" style="background-image: url(<?=base_url().$topic->topic_news_picture;?>)">
                        <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>"></a>
                    </div>
                    <header>
                        <h1>
                        <a href="<?=site_url('home/detail').'/'.$topic->topic_news_id?>">
                        <?php echo $topic->topic_news_title;?>
                        </a>
                        <span class="social <?php echo $topic->top;?>" style="display: inline;"><?php echo $topic->top;?></span>
                        </h1>
                        <time datetime="<?=date('Y-m-d H:i:s', $topic->topic_news_date)?>"></time>
                        <p class="cate"><?php echo $category_name;?></p>
                    </header>
                </article>
                <?php } endif;?>
            </section>

            <section style="display: block;" id="promotedposts">
                <header>
                <h1><a href="http://news.zing.vn/thi-truong/TTDN.html" title="Thông tin doanh nghiệp">Thông tin doanh nghiệp </a></h1>
                </header>

                <article style="display: block;">
                    <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC2_N3/2014_02_26/FPT_telecom.jpg)">
                    <a href="http://news.zing.vn/FPT-Telecom-thuc-hien-Nam-trat-tu-va-van-minh-do-thi-2014-post394845.html#category_sidebar.pr"></a>
                    </div>
                    <header>
                    <h1>
                    <a href="http://news.zing.vn/FPT-Telecom-thuc-hien-Nam-trat-tu-va-van-minh-do-thi-2014-post394845.html#category_sidebar.pr">
                    FPT Telecom thực hiện 'Năm trật tự và văn minh đô thị 2014'
                    </a>

                    </h1>
                    </header>
                </article>

                <article>
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_25/Anh.jpg)">
                        <a href="http://news.zing.vn/Tien-ich-cho-khach-hang-Agribank-khi-thanh-toan-truc-tuyen-post394652.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/Tien-ich-cho-khach-hang-Agribank-khi-thanh-toan-truc-tuyen-post394652.html#category_sidebar.pr">
                        Tiện ích cho khách hàng Agribank khi thanh toán trực tuyến 
                        </a>

                        </h1>
                        </header>
                </article>

                <article>
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_24/IMG_3104.JPG)">
                        <a href="http://news.zing.vn/Nhung-thoi-quen-xau-anh-huong-den-rang-mieng-o-tre-em-post394252.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/Nhung-thoi-quen-xau-anh-huong-den-rang-mieng-o-tre-em-post394252.html#category_sidebar.pr">
                        Những thói quen xấu ảnh hưởng đến răng miệng ở trẻ em
                        </a>

                        </h1>
                        </header>
                </article>

                <article style="display: block;">
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC2_N3/2014_02_25/Honda_Viet_Nam_to_chuc_cuoc_thi_1.jpg)">
                        <a href="http://news.zing.vn/400000-giao-vien-va-hoc-sinh-thi-An-toan-giao-thong-post394602.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/400000-giao-vien-va-hoc-sinh-thi-An-toan-giao-thong-post394602.html#category_sidebar.pr">
                        400.000 giáo viên và học sinh thi 'An toàn giao thông' 
                        </a>

                        </h1>
                        </header>
                </article>

                <article style="display: block;">
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_25/iphone4s64gbwhite2_g257_0.jpg)">
                        <a href="http://news.zing.vn/iPhone-4-va-4s-gia-tot-do-FPT-phan-phoi-post394493.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/iPhone-4-va-4s-gia-tot-do-FPT-phan-phoi-post394493.html#category_sidebar.pr">
                        iPhone 4 và 4s giá tốt do FPT phân phối
                        </a>

                        </h1>
                        </header>
                </article>

                <article>
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC2_N3/2014_02_24/Sinh_vien_BUV_thuc_tap_tai_cong_ty_chung_khoan_Sai_Gon_1.jpg)">
                        <a href="http://news.zing.vn/Thach-thuc-va-co-hoi-khi-theo-hoc-Tai-chinh--ngan-hang-post394301.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/Thach-thuc-va-co-hoi-khi-theo-hoc-Tai-chinh--ngan-hang-post394301.html#category_sidebar.pr">
                        Thách thức và cơ hội khi theo học Tài chính - ngân hàng
                        </a>

                        </h1>
                        </header>
                </article>

                <article style="display: block;">
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_24/hinh1.jpg)">
                        <a href="http://news.zing.vn/6-ly-do-khien-BlackBerry-Z10-tro-thanh-smartphone-dang-chon-post394332.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/6-ly-do-khien-BlackBerry-Z10-tro-thanh-smartphone-dang-chon-post394332.html#category_sidebar.pr">
                        6 lý do khiến BlackBerry Z10 trở thành smartphone đáng chọn
                        </a>

                        </h1>
                        </header>
                </article>

                <article>
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC2_N3/2014_02_24/N5.png)">
                        <a href="http://news.zing.vn/Pham-Hoang-Nam-muon-tien-xa-hon-trong-lang-nguoi-mau-post394245.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/Pham-Hoang-Nam-muon-tien-xa-hon-trong-lang-nguoi-mau-post394245.html#category_sidebar.pr">
                        Phạm Hoàng Nam muốn tiến xa hơn trong làng người mẫu
                        </a>

                        </h1>
                        </header>
                </article>

                <article>
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_24/z_02.jpg)">
                        <a href="http://news.zing.vn/Luot-Yes24-lai-Vespa-80-trieu-ve-nha-post394210.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/Luot-Yes24-lai-Vespa-80-trieu-ve-nha-post394210.html#category_sidebar.pr">
                        Lướt Yes24, lái Vespa 80 triệu về nhà
                        </a>

                        </h1>
                        </header>
                </article>

                <article style="display: block;">
                        <div class="cover" style="background-image: url(http://img.v3.news.zdn.vn/w480/Uploaded/JAC1_N3/2014_02_24/image001.jpg)">
                        <a href="http://news.zing.vn/Mua-dien-thoai-may-tinh-bang-Samsung-nhan-qua-khung-post394159.html#category_sidebar.pr"></a>
                        </div>
                        <header>
                        <h1>
                        <a href="http://news.zing.vn/Mua-dien-thoai-may-tinh-bang-Samsung-nhan-qua-khung-post394159.html#category_sidebar.pr">
                        Mua điện thoại, máy tính bảng Samsung, nhận quà khủng
                        </a>

                        </h1>
                        </header>
                </article>

            </section>
            <script>
                var posts = $('#promotedposts article');
                if ($(posts).length <= 5) {
                    $('#promotedposts article').show();
                    $('#promotedposts').show();
                } else {
                    var display = [];
                    while (display.length < 5) {
                        i = Math.floor(Math.random() * $(posts).length);
                        if (display.indexOf(i) == -1) display.push(i);
                    }
                    for (var i = 0, j = display.length; i < j; i++) {
                        $($(posts)[display[i]]).show();
                    };
                    $('#promotedposts').show();
                }
            </script>

    </section>

</section>
